/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.comeval.modelo;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author LUISA
 */
@Entity
@Table(name = "factura")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Factura.findAll", query = "SELECT f FROM Factura f"),
    @NamedQuery(name = "Factura.findByCodigofactura", query = "SELECT f FROM Factura f WHERE f.codigofactura = :codigofactura"),
    @NamedQuery(name = "Factura.findByFechafactura", query = "SELECT f FROM Factura f WHERE f.fechafactura = :fechafactura"),
    @NamedQuery(name = "Factura.findBySubtotalfactura", query = "SELECT f FROM Factura f WHERE f.subtotalfactura = :subtotalfactura"),
    @NamedQuery(name = "Factura.findByIvafactura", query = "SELECT f FROM Factura f WHERE f.ivafactura = :ivafactura"),
    @NamedQuery(name = "Factura.findByTotalfactura", query = "SELECT f FROM Factura f WHERE f.totalfactura = :totalfactura"),
    @NamedQuery(name = "Factura.findByFormadepago", query = "SELECT f FROM Factura f WHERE f.formadepago = :formadepago")})
public class Factura implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "codigofactura")
    private Long codigofactura;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "fechafactura")
    private String fechafactura;
    @Basic(optional = false)
    @NotNull
    @Column(name = "subtotalfactura")
    private int subtotalfactura;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ivafactura")
    private int ivafactura;
    @Basic(optional = false)
    @NotNull
    @Column(name = "totalfactura")
    private long totalfactura;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "formadepago")
    private String formadepago;
    @JoinColumn(name = "codigopedido", referencedColumnName = "codigopedido")
    @ManyToOne(optional = false)
    private Productopedido codigopedido;

    public Factura() {
    }

    public Factura(Long codigofactura) {
        this.codigofactura = codigofactura;
    }

    public Factura(Long codigofactura, String fechafactura, int subtotalfactura, int ivafactura, long totalfactura, String formadepago) {
        this.codigofactura = codigofactura;
        this.fechafactura = fechafactura;
        this.subtotalfactura = subtotalfactura;
        this.ivafactura = ivafactura;
        this.totalfactura = totalfactura;
        this.formadepago = formadepago;
    }

    public Long getCodigofactura() {
        return codigofactura;
    }

    public void setCodigofactura(Long codigofactura) {
        this.codigofactura = codigofactura;
    }

    public String getFechafactura() {
        return fechafactura;
    }

    public void setFechafactura(String fechafactura) {
        this.fechafactura = fechafactura;
    }

    public int getSubtotalfactura() {
        return subtotalfactura;
    }

    public void setSubtotalfactura(int subtotalfactura) {
        this.subtotalfactura = subtotalfactura;
    }

    public int getIvafactura() {
        return ivafactura;
    }

    public void setIvafactura(int ivafactura) {
        this.ivafactura = ivafactura;
    }

    public long getTotalfactura() {
        return totalfactura;
    }

    public void setTotalfactura(long totalfactura) {
        this.totalfactura = totalfactura;
    }

    public String getFormadepago() {
        return formadepago;
    }

    public void setFormadepago(String formadepago) {
        this.formadepago = formadepago;
    }

    public Productopedido getCodigopedido() {
        return codigopedido;
    }

    public void setCodigopedido(Productopedido codigopedido) {
        this.codigopedido = codigopedido;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codigofactura != null ? codigofactura.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Factura)) {
            return false;
        }
        Factura other = (Factura) object;
        if ((this.codigofactura == null && other.codigofactura != null) || (this.codigofactura != null && !this.codigofactura.equals(other.codigofactura))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.comeval.modelo.Factura[ codigofactura=" + codigofactura + " ]";
    }
    
}
